package com.itheima.ExtendsClass;

import java.awt.*;
import java.awt.image.BufferedImage;

public class Fly {
    protected   int x ;
    protected  int y;
    protected  int width;
    protected int hight;
    protected BufferedImage img;


    public Fly() {
    }

    public Fly(int x, int y, int width, int hight,BufferedImage img) {
        this.x = x;
        this.y = y;
        this.width = width;
        this.hight = hight;
        this.img = img;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public int getWidth() {
        return width;
    }

    public void setWidth(int width) {
        this.width = width;
    }

    public int getHight() {
        return hight;
    }

    public void setHight(int hight) {
        this.hight = hight;
    }

    public BufferedImage getImg() {
        return img;
    }

    public void setImg(BufferedImage img) {
        this.img = img;
    }

    public void draw(Graphics g) {
        g.drawImage(this.getImg(), this.x, this.y, this.width, this.hight, null);
    }

    public boolean judge(Fly fly) {
        boolean r = fly.y < this.y + this.hight && fly.y + fly.hight > this.y
                && fly.x + fly.width > this.x && fly.x < this.x + this.width;
        return r;
    }

    }


